import request from '@/utils/request'
/**
 * 查询全部
 * @param {*} datas
 */
export function queryList(datas) {
  return request({
    url: '/smc/api/orginfo',
    method: 'get',
    params: {
      flag: datas.flag,
      superiororg: datas.superiororg,
      pageNum: datas.pageNum,
      pageSize: datas.pageSize
    }
  })
}

/**
 * 根据参数查询
 * @param {*} datas
 */
export function queryListByParam(datas) {
  return request({
    url: '/smc/api/orginfo',
    method: 'get',
    params: {
      orgname: datas.queryParam,
      pageSize: datas.pageSize,
      pageNum: datas.pageNum
    }
  })
}

/**
 * 根据机构id查询已分配与未分配的岗位列表
 * @param {*} orgid
 */
export function queryListForPoslist(orgid) {
  return request({
    url: '/smc/api/getPositioninfoListByOrgId/' + orgid,
    method: 'get'
  })
}

/**
 * 设置岗位信息
 * @param {*} datas
 */
export function setPositionToOrg(datas) {
  return request({
    url: '/smc/api/setPositionToOrg/' + datas.orgid + '/' + datas.posids,
    method: 'get'
  })
}

/**
 * 撤销岗位信息
 * @param {*} datas
 */
export function deletePositionToOrg(datas) {
  return request({
    url: '/smc/api/deletePositionToOrg/' + datas.orgid + '/' + datas.posids,
    method: 'get'
  })
}

/**
 * 根据机构id与岗位id获取岗位人员信息列表
 * @param {*} datas
 */
export function getUserFromPosition(datas) {
  return request({
    url: '/smc/api/getUserFromPosition/' + datas.orgid + '/' + datas.posid,
    method: 'get'
  })
}

/**
 * 查询用户信息
 * @param {*} datas
 */
export function userQueryList(datas) {
  return request({
    url: '/smc/api/userinfo',
    method: 'get',
    params: {
      queryPara: datas.queryPara,
      orgid: datas.orgid,
      pageSize: datas.pageSize,
      pageNum: datas.pageNum
    }
  })
}

/**
 * 根据组织机构ID、 岗位ID、 用户ID列表， 设置指定机构岗位下的用户信息
 * @param {*} datas
 */
export function setUserToPosition(datas) {
  return request({
    url: '/smc/api/setUserToPosition/' + datas.orgid + '/' + datas.posid + '/' + datas.userids,
    method: 'get'
  })
}

/**
 * 批量删除
 * @param {*} ids
 */
export function deletes(orgids) {
  return request({
    url: '/smc/api/deleteOrginfo/' + orgids,
    method: 'get'
  })
}

/**
 * 新增 object
 * @param datas
 */
export function add(datas) {
  return request({
    url: '/smc/api/orginfo',
    method: 'post',
    data: {
      orgid: datas.orgid,
      orgname: datas.orgname,
      orgno: datas.orgno,
      principal: datas.principal,
      innerno: datas.innerno,
      superiororg: datas.superiororg,
      virflg: datas.virflg,
      status: datas.status,
      fax: datas.fax,
      telephone: datas.telephone,
      address: datas.address,
      extend1: datas.extend1,
      extend2: datas.extend2,
      extend3: datas.extend3,
      extend4: datas.extend4,
      extend5: datas.extend5,
      extend6: datas.extend6
    }
  })
}

/**
 * 修改 object
 * @param datas
 */
export function update(datas) {
  return request({
    url: '/smc/api/orginfo',
    method: 'put',
    data: {
      orgid: datas.orgid,
      orgname: datas.orgname,
      orgno: datas.orgno,
      principal: datas.principal,
      innerno: datas.innerno,
      superiororg: datas.superiororg,
      virflg: datas.virflg,
      status: datas.status,
      fax: datas.fax,
      telephone: datas.telephone,
      address: datas.address,
      extend1: datas.extend1,
      extend2: datas.extend2,
      extend3: datas.extend3,
      extend4: datas.extend4,
      extend5: datas.extend5,
      extend6: datas.extend6
    }
  })
}

